package com.itheima02;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapTest01 {
    public static void main(String[] args) {
        HashMap<Student,String> hm = new HashMap<>();

        Student s1 = new Student("张三",23);
        Student s2 = new Student("李四",24);
        Student s3 = new Student("王五",15);
        Student s4 = new Student("赵六",22);
        Student s5= new Student("赵六",22);

        hm.put(s1,"it001");
        hm.put(s2,"it002");
        hm.put(s3,"it003");
        hm.put(s4,"it004");
        hm.put(s5,"it005");

        Set<Student> set1 = hm.keySet();
        for (Student stu1 : set1) {
            String s = hm.get(stu1);
            System.out.println(stu1.getName()+"---"+stu1.getAge()+"---"+s);
        }
        System.out.println("---------------------------");
        Set<Map.Entry<Student, String>> entries = hm.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            Student stu1 = entry.getKey();
            String s = entry.getValue();
            System.out.println(stu1.getName()+"---"+stu1.getAge()+"---"+s);
        }

    }
}
